package com.hmall.item.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hmall.item.mapper.ItemMapper;
import com.hmall.item.pojo.Item;
import com.hmall.item.service.IItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class ItemService extends ServiceImpl<ItemMapper, Item> implements IItemService {

    @Autowired
    private ItemMapper itemMapper;

    @Transactional
    @Override
    public void updateItem(Long id, Integer status) {
        Item item = itemMapper.selectById(id);
        if (status == 2) {
            item.setStatus(2);
            itemMapper.updateById(item);
        } else {
            item.setStatus(1);
            itemMapper.updateById(item);
        }

    }
}
